package com.osiatis.epitech;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import netsoul.connect.INetsoulListener;
import netsoul.connect.NetsoulConnect;

import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Note;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.CursorLoader;
import android.content.Intent;
import android.database.Cursor;
import android.sax.TextElementListener;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class SimpleActivity extends Activity implements INetsoulListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_simple);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_simple, menu);
		return true;
	}
	
	public boolean connect(View v) {
		Log.i("NetSoul","Connect Clicked !");
		//getContacts();
		EditText edit = (EditText) findViewById(R.id.editLogin);
		String login = edit.getText().toString();
		edit = (EditText) findViewById(R.id.editPassword);
		String password_socks = edit.getText().toString();
		NetsoulConnect nc = NetsoulConnect.getInstance(login, password_socks);
		nc.setNetsoulListener(this);
		nc.connect();
		return true;
	}

	@Override
	public void onNetsoulError(Exception ex) {
		Log.d("NetSoul", "connection error", ex);
	}

	@Override
	public void onNetsoulConnect() {
		Log.i("NetSoul", "connection OK");
		Intent intent = new Intent(getApplicationContext(), UserListActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		getApplicationContext().startActivity(intent);
	}

	@Override
	public void onNetsoulDisconnect() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onNetsoulMessage(String message) {
		// TODO Auto-generated method stub
		
	}
 	
    

}
